import paramiko

def rcmd(host, username='root', port=22, password=None, cmds=None):
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(host, port=port, username=username, password=password)
    stdin, stdout, stderr = ssh.exec_command(cmds)
    out = stdout.read()
    err = stderr.read()
    if out:
        print('[%s] OUT:\n%s' %(host,out.decode()))
    if err:
        print('[%s] ERROR:\n%s' %(host,err.decode()))
    ssh.close()

if __name__ == '__main__':
    rcmd('172.25.0.11', password='redhat', cmds='id root;id zhangsan')
